#pragma once
#include "HashTable.h"

namespace LL
{
	template<class K, class V, class HashFunc = DefalutType<K>>
	class unordered_map
	{
		struct KeyOfT_Map
		{
			const K& operator()(const pair<const K, V>& kv)
			{
				return kv.first;
			}
		};
	public:
		typedef typename HashTable<const K, pair<const K, V>, HashFunc, KeyOfT_Map>::iterator iterator;
		typedef typename HashTable<const K, pair<const K, V>, HashFunc, KeyOfT_Map>::const_iterator const_iterator;

		iterator begin()
		{
			return _ht.begin();
		}
		iterator end()
		{
			return _ht.end();
		}
		pair<iterator, bool> insert(const pair<K, V>& kv)
		{
			return _ht.insert(kv);
		}

		V& operator[](const K& key)
		{
			pair<iterator, bool> ret = _ht.insert(make_pair(key, V()));
			return ret.first->second;
		}

	private:
		HashTable<const K, pair<const K, V>, HashFunc, KeyOfT_Map> _ht;
	};
}